package com.pingxx.demo.controller;

import com.pingxx.demo.kafka.TopicConsts;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class KafkaController {

    @Autowired
    private KafkaTemplate kafkaTemplate;

    @GetMapping("kafka")
    public String kafka(String message) {
        kafkaTemplate.send(TopicConsts.SAMPLE_TOPIC, message);
        return "Hello Kafka";
    }
}
